//
//  LDForgotViewController.swift
//  DingDongZP
//
//  Created by 三秒文化 on 16/6/27.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

class LDForgotPsVC: LDLoginBaseVC {

    override func viewDidLoad() {
        super.viewDidLoad()
        enterBtn.setTitle("重置密码", forState: .Normal)
    }
    
   
    
    override func enterClick() {
        
        let phone = phoneTextField.text ?? ""
        let password = passwordTextField.text ?? ""
        let code = securityCodeTextField.text ?? ""
        
        let params = ["mobile":phone,"password":password,"code":code]
        
        LDCheckPublicInfo.shareInstance.resetPassword(params, succ: { [weak self] in
            
            DDLoginUserManager.clearLoginInfo()
            self?.navigationController?.popViewControllerAnimated(true)
        
        }) { (data) in
            
            let noticeStr = data as? String ?? "重置失败,请重试"
            LDShowHUB.shareInstance.showBarStatus(noticeStr)
        }
        
    }
    
    override func changStatus(btn: UIButton) {
        
        if btn.tag == passwordtag {
            
            passwordTextField.secureTextEntry = !passwordTextField.secureTextEntry
            
        } else if btn.tag == securitytag {//获取验证码
            getcodeBtn.userInteractionEnabled = false
            
            requestCodeNet()
            
        }
    }
    
    override func keyboardHidden(noti: NSNotification?) {
        super.keyboardHidden(noti)
        navigationItem.title = ""
        
    }
    
    override func keyboardShow(noti: NSNotification) {
        super.keyboardShow(noti)
        navigationItem.title = "重置密码"
    }

}
